package edu.zut.hb.ambition.inhospitaltype.domain;



import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.inhospitaltype;
import com.ruoyi.system.service.IinhospitaltypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;


@RestController
@RequestMapping("/system/inhospitaltype")
public class inhospitaltypeGroup extends BaseController
{
    @Autowired
    private IinhospitaltypeService inhospitaltypeService;

    /**
     * 查询住院缴费列表
     */
    @PreAuthorize("@ss.hasPermi('system:inhospitaltype:list')")
    @GetMapping("/list")
    public TableDataInfo list(inhospitaltype inhospitaltype)
    {
        startPage();
        List<inhospitaltype> list = inhospitaltypeService.selectinhospitaltypeList(inhospitaltype);
        return getDataTable(list);
    }

    /**
     * 导出住院缴费列表
     */
    @PreAuthorize("@ss.hasPermi('system:inhospitaltype:export')")
    @Log(title = "住院缴费", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, inhospitaltype inhospitaltype)
    {
        List<inhospitaltype> list = inhospitaltypeService.selectinhospitaltypeList(inhospitaltype);
        ExcelUtil<inhospitaltype> util = new ExcelUtil<inhospitaltype>(inhospitaltype.class);
        util.exportExcel(response, list, "住院缴费数据");
    }

    /**
     * 获取住院缴费详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:inhospitaltype:query')")
    @GetMapping(value = "/{inhospitalid}")
    public AjaxResult getInfo(@PathVariable("inhospitalid") Long inhospitalid)
    {
        return AjaxResult.success(inhospitaltypeService.selectinhospitaltypeByInhospitalid(inhospitalid));
    }

    /**
     * 新增住院缴费
     */
    @PreAuthorize("@ss.hasPermi('system:inhospitaltype:add')")
    @Log(title = "住院缴费", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody inhospitaltype inhospitaltype)
    {
        return toAjax(inhospitaltypeService.insertinhospitaltype(inhospitaltype));
    }

    /**
     * 修改住院缴费
     */
    @PreAuthorize("@ss.hasPermi('system:inhospitaltype:edit')")
    @Log(title = "住院缴费", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody inhospitaltype inhospitaltype)
    {
        return toAjax(inhospitaltypeService.updateinhospitaltype(inhospitaltype));
    }

    /**
     * 删除住院缴费
     */
    @PreAuthorize("@ss.hasPermi('system:inhospitaltype:remove')")
    @Log(title = "住院缴费", businessType = BusinessType.DELETE)
    @DeleteMapping("/{inhospitalids}")
    public AjaxResult remove(@PathVariable Long[] inhospitalids)
    {
        return toAjax(inhospitaltypeService.deleteinhospitaltypeByInhospitalids(inhospitalids));
    }
}
